package com.leyou.config;

import com.alibaba.druid.pool.DruidDataSource;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import javax.sql.DataSource;

@Configuration
@EnableConfigurationProperties(JdbcProperties.class)
public class JdbcConfig {
@Bean
    public DataSource getDataSource(JdbcProperties jdbcProperties){
    DruidDataSource dataSource = new DruidDataSource();
    dataSource.setDriverClassName(jdbcProperties.getDriverClassName());
    dataSource.setUrl(jdbcProperties.getUrl());
    dataSource.setUsername(jdbcProperties.getUsername());
    dataSource.setPassword(jdbcProperties.getPassword());
    return dataSource;
}
}
